<?php
defined('OA_LIB_PATH') || define('OA_LIB_PATH', '/opt/op/OALib');
defined('OPEN_LIB_PATH') || define('OPEN_LIB_PATH', '/opt/op/OpenLib');

require_once 'PHPUnit/Framework.php';
require_once 'Log.php';
require_once OPEN_LIB_PATH . '/open/models/OaOnlineModel.php';
require_once OPEN_LIB_PATH . '/open/models/OaAppModel.php';

class OaOnlineModelTest extends PHPUnit_Framework_TestCase
{
    private $_logger;
    private $_model;
    
    protected function setUp()
    {
        $logger = Log::factory('console', '', '', array(), PEAR_LOG_INFO);
        $this->_logger = $logger;
        $this->_model = new OaOnlineModel($logger);
    }
    
    protected function tearDown()
    {
        
    }
    
    /**
     * @dataProvider provider
     */
    public function testAddAppSnapshot($appId)
    {
        $this->markTestSkipped();
        $appConfigOrderModel = new OaAppConfigOrderModel();
        $order = $appConfigOrderModel->getAppLastConfigOrder($appId);
        $result = $this->_model->addAppSnapshot($order['id']);
        $this->assertTrue($result);
    }
    
    /**
     * @dataProvider provider
     */
    public function testGetAppOnline($appId)
    {
        $result = $this->_model->getAppOnline($appId);
        $this->_logger->info($result);
        $this->assertTrue(is_array($result));
    }
    
    /**
     * @dataProvider provider
     */
    public function testModifyAppOnline($appId)
    {
        $result = $this->_model->modifyAppOnline($appId, array(
            'name' => 'jag app'
        ));
        $this->assertTrue($result);
    }
    
    public function provider()
    {
        return array(
            array(1)
        );
    }
}
